
// ---- End Project Data ----


// ---- File Buttons.t ----

// Before Script for "baseView"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

baseView :=
   {title: "Buttons",
    viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
    viewSetupFormScript:
      func()
      begin
      	// resize to fit on all "small" newtons.
      	local b := GetAppParams();
      	constant kMaxWidth := 240;
      	constant kMaxHeight := 336;
      	self.viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop,
      										  MIN(b.appAreaWidth, kMaxWidth),
      										  MIN(b.appAreaHeight, kMaxHeight));
      end,
    _proto: protoApp,
    debug: "baseView"
   };


// Before Script for "label1"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

label1 := /* child of baseView */
   {text: "Example of a popup text button:",
    viewBounds: {left: 9, top: 17, right: 193, bottom: 41},
    viewJustify: 0,
    viewFont: simpleFont9,
    _proto: protoStaticText,
    debug: "label1"
   };
// View label1 is declared to baseView




// Before Script for "PopupButton"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

PopupButton := /* child of baseView */
   {text: "PopUp",
    viewBounds: {left: 75, top: 35, right: 147, bottom: 51},
    buttonClickScript:
      func()
      begin
      // note 0,0 for a topLeft is probably not as pretty as
      // some things could be
          DoPopup(popupList, 0, 0, self);
      end,
    popupList: ["No", "No Way", "Never", "Over My Dead Body"],
    pickActionScript:
      func(index)
      // note you need to implement pickActionScript if you have a popupList
      begin
          Print("Selected index no " & index);
      end,
    pickCancelledScript:
      func()
      begin
          Print("Popup cancelled");
      end,
    _proto: protoTextButton,
    debug: "PopupButton"
   };
// View PopupButton is declared to baseView




// Before Script for "label2"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

label2 := /* child of baseView */
   {text: "Example of a movable palette of buttons:",
    viewBounds: {left: 9, top: 74, right: 193, bottom: 106},
    viewJustify: 0,
    viewFont: simpleFont9,
    _proto: protoStaticText,
    debug: "label2"
   };




// Before Script for "label3"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

label3 := /* child of baseView */
   {text: "Example of buttons that show states using drawing:",
    viewBounds: {left: 9, top: 168, right: 196, bottom: 196},
    viewJustify: 0,
    viewFont: simpleFont9,
    _proto: protoStaticText,
    debug: "label3"
   };




// Before Script for "statusButton"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

statusButton := /* child of baseView */
   {viewFlags: 513,
    viewFormat: 83887089,
    viewBounds: {left: 28, top: 103, right: 202, bottom: 145},
    viewClickScript:
      func(unit)
      begin
          :Drag(unit, nil);    // move the button palette
          true;
      end,
    viewclass: 74,
    debug: "statusButton"
   };


// Before Script for "butt1"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

butt1 := /* child of statusButton */
   {text: "First",
    viewBounds: {left: 18, top: 18, right: 58, bottom: 34},
    buttonClickScript:
      func()
      begin
          Print("Button 1 clicked -- buttonPalette");
      end,
    _proto: protoTextButton,
    debug: "butt1"
   };
// View butt1 is declared to statusButton




// Before Script for "butt2"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

butt2 := /* child of statusButton */
   {text: "Second",
    viewBounds: {left: 66, top: 18, right: 106, bottom: 34},
    buttonClickScript:
      func()
      begin
          Print("Button 2 clicked -- buttonPalette");
      end,
    _proto: protoTextButton,
    debug: "butt2"
   };
// View butt2 is declared to statusButton




// Before Script for "butt3"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

butt3 := /* child of statusButton */
   {text: "Third",
    viewBounds: {left: 114, top: 18, right: 162, bottom: 34},
    buttonClickScript:
      func()
      begin
          Print("Button 3 clicked -- buttonPalette");
      end,
    _proto: protoTextButton,
    debug: "butt3"
   };
// View butt3 is declared to statusButton




// Before Script for "_view000"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

_view000 := /* child of statusButton */
   {text: "Move me around!",
    viewBounds: {left: 7, top: 2, right: 97, bottom: 11},
    _proto: protoStaticText
   };






// Before Script for "StateButton"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

StateButton := /* child of baseView */
   {text: "Status",
    viewBounds: {left: 75, top: 200, right: 142, bottom: 223},
    viewJustify: 5,
    theState: 'closed,
    viewSetupFormScript:
      func()
      begin
      // create the triangle object
          closedTShape := MakePolygon('[5,5,10,10,5,15,5,5]);
          openTShape := MakePolygon('[0,10,10,10,5,15,0,10]);
      end,
    OpenTShape: nil,
    ClosedTShape: nil,
    viewDrawScript:
      // draw a notification inside the button
      
      func()
      begin
          if (theState = 'closed) then
              :DrawShape(ClosedTShape, nil);
      
          if (theState = 'open) then
              :DrawShape(OpenTShape, nil);
      end,
    buttonClickScript:
      func()
      begin
      // switch between two states
          if theState = 'closed then
              theState := 'open;
          else
              theState := 'closed;
      
          :Dirty();            // force a dirty after this
      end,
    viewFormat: 67306065,
    _proto: protoTextButton,
    debug: "StateButton"
   };




// Before Script for "label4"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

label4 := /* child of baseView */
   {
    text:
      "Example of Button that looks like the protoShowBar (used for filing):",
    viewBounds: {left: 9, top: 249, right: 193, bottom: 281},
    viewJustify: 0,
    viewFont: simpleFont9,
    _proto: protoStaticText,
    debug: "label4"
   };




// Before Script for "showBarButton"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

showBarButton := /* child of baseView */
   {text: "Button",
    buttonClickScript:
      // When clicked, call DoPopUp and send over the array of labels.
      func()
      begin
      // Note that we are creating the frame array in RAM, why? Well,
      // if the frame was pre-defined in the slot, it would be a ROM-readonly
      // entity, and we would be unable to change the items on the flight --
      // unless you cloned the whole frame and started to add more array entries
      // to this cloned RAM object. Anyway, you are able to do both, I just showed
      // the dynamic way of doing this, and I'm sure there are more designed ways
      // to add entries to the popup frame.
      
          pop := SetLength([], 6);         // preallocate an array
      
      // Create the frame.
      // Only one should have the mark, decide this here as well
      
         pop[0] := { item: "Unfiled", mark: $ }; 
         IF currentSelection = 0 THEN
            pop[0].mark := $\u221A;
      
         pop[1] := { item: "Business", mark: $ };
         IF currentSelection = 1 THEN
            pop[1].mark := $\u221A;
      
         pop[2] := { item: "Private", mark:  $ };
         IF currentSelection = 2 THEN
            pop[2].mark := $\u221A;
      
         pop[3] := { item: "Important", mark: $ };
         IF currentSelection = 3 THEN
            pop[3].mark := $\u221A;
      
         pop[4] := 'pickSeparator;
      
         pop[5] := { item: "Everything", mark: $ };
         IF currentSelection = 5 THEN
            pop[5].mark := $\u221A;
       
         DoPopUp(pop, 0, 2, self);
      
      // Another thing to remember with dynamic popups is that if you don't
      // know the length and width of the strings, you have to precalculate
      // this information using StrFontWidth and maybe truncate using StrTruncate.
      
      end,
    viewBounds: {left: 74, top: 290, right: 145, bottom: 301},
    pickActionScript:
      // Update the label text in the button with the newly defined
      // value.
      func(index)
      begin
      // Get access to the newly selected value, and store it 
         currentSelection := index;
      
      // Create new text and set it
         SetValue(self, 'text,  $\uFC01 && pop[currentSelection].item);
      end,
    currentSelection: nil,
    viewSetupFormScript:
      func()
      begin
         currentSelection := 0;      // default label
      
      // In real life we would maybe get a default label and stuff it
      // in here based on the currentSelection, or then do as I did below,
      // create an undefined label, forcing the end user to select a
      // label. Maybe a default label is a more user friendly thing to
      // do...
      
         text := $\uFC01 && "Undefined";
      end,
    viewFormat: 337,
    pop: nil,
    _proto: protoTextButton,
    debug: "showBarButton"
   };




// Before Script for "line1"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

line1 := /* child of baseView */
   {viewBounds: {left: 1, top: 68, right: 244, bottom: 70},
    _proto: protoBorder,
    debug: "line1"
   };




// Before Script for "line2"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

line2 := /* child of baseView */
   {viewBounds: {left: 1, top: 161, right: 244, bottom: 163},
    _proto: protoBorder,
    debug: "line2"
   };




// Before Script for "line3"
// Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.

line3 := /* child of baseView */
   {viewBounds: {left: -6, top: 241, right: 237, bottom: 243},
    _proto: protoBorder,
    debug: "line3"
   };







// ---- Beginning of section for non used Layout files ----

// End of output